package com.punch.common.dto.order;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * OrderDTO-订单信息 表单
 *
 * @author xiaol
 * @version 1.0.0
 * @since 2020/8/3
 */
@Data
public class OrderDTO implements Serializable {

    @ApiModelProperty(hidden = true)
    private Long orderId;

    @ApiModelProperty(hidden = true)
    private String orderSN;

    @ApiModelProperty(hidden = true)
    private LocalDateTime createTime;

    @ApiModelProperty(name = "orderType", notes = "订单类型 0-未知 1-三点半订单")
    @NotNull(message = "订单类型为空")
    private Integer orderType;


    @ApiModelProperty(name = "studentId", notes = "学生id")
    @NotNull(message = "学生为空")
    private Long studentId;

    @ApiModelProperty(name = "studentName", notes = "学生姓名")
    private String studentName;

    @ApiModelProperty(name = "totalAmount", notes = "订单总价格,单位分,包括产品价,后期有可能有运费之类的其余费用")
    @NotNull(message = "总价格为空")
    @Min(value = 0, message = "总价格不能为负数")
    private Integer totalAmount;


    @ApiModelProperty(name = "orderAmount", notes = "订单总价格,用户需支付的金额,有可能使用优惠券,方便扩展")
    @NotNull(message = "订单总价格为空")
    @Min(value = 0, message = "订单总价格不能为负数")
    private Integer orderAmount;

    @ApiModelProperty(name = "originalAmount", notes = "所有产品的金额相加")
    @NotNull(message = "产品总价为空")
    @Min(value = 0, message = "产品总价不能为负数")
    private Integer originalAmount;

    @ApiModelProperty(name = "payChannel", notes = "支付渠道 ZERO-无支付 ALIPAY_APP-支付宝APP,WXPAY_APP-微信APP")
    @NotEmpty(message = "支付渠道为空")
    private String payChannel;


    @ApiModelProperty(name = "payType", notes = "支付类型 0-(0元订单)无支付 1-在线支付")
    private Integer payType;

    @JsonInclude
    private String clientIp;

    @JsonInclude
    private String body;


    @ApiModelProperty(name = "productList", notes = "产品列表,本次版本为课程与教具")
    @NotNull(message = "产品为空")
    @NotNull.List(@NotNull(message = "产品为空"))
    private @Valid List<OrderDetailDTO> productList;
}
